﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using com.vs.DataAccess;
using com.vs.DataAccess.DO;
using com.vs.General;
using com.vs.General.RF;
using com.vs.Receiving.BL;
using com.vs.Inventory.BL;

namespace com.vs.RF.Web.receiving
{
    public partial class CheckInQtyEntryHandling : RFHandlingPage
    {
        protected int iBaseQty = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            stSourcePage = "receiving/CheckInQtyEntry.aspx";
            stTargetPage = "receiving/LPNEntry.aspx";

            go();
        }

        protected override void parseRequest()
        {
            iBaseQty = Convert.ToInt32(this.Request["hdBaseQty"]);
        }

        protected override void procData()
        {
            ReceiptContainerDO rcDO = null;
            ReceiptContManager rcMgr = null;

            try
            {
                rcMgr = new ReceiptContManager();
                rcDO = rcMgr.NewReceiptContainer(rfSess, Convert.ToInt32(Session[RFSupport.INTERNAL_RECEIPT_LINE_NUM]));
                rcDO.QUANTITY = iBaseQty;
                Session[RFSupport.RECEIPT_CONTAINER_DO] = rcDO;

                ItemDO itmDO = (ItemDO)Session[RFSupport.ITEM_DO];
                if (StringManager.Equals(itmDO.ATTRIBUTE_TRACK, "Y"))
                    stTargetPage = "AttributeEntry.aspx";
                else
                {
                    ReceivingPreferenceDO prefDO = (ReceivingPreferenceDO)Session[RFSupport.RECEIVING_PREFERENCE_DO];
                    if (StringManager.Equals(prefDO.AUTO_ASSIGN_LPN, "N"))
                        stTargetPage = "LPNEntry.aspx";
                    else
                        stTargetPage = "LPNEntryHandling.aspx";
                }

            }
            catch (Exception ex)
            {
                ExceptionManager.LogException(rfSess, ex);
                this.stError = ex.Message;
            }
        }
    }
}
